

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>layuiAdmin 管理员 iframe 框</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
</head>
<body>

  <div class="layui-form" lay-filter="layuiadmin-form-admin" id="layuiadmin-form-admin" style="padding: 20px 30px 0 0;">
    <div class="layui-form-item">
      <label class="layui-form-label">登录名</label>
      <div class="layui-input-inline">
        <input type="text" name="userName" lay-verify="required" placeholder="请输入用户名" id="userName" autocomplete="off" class="layui-input">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">密码</label>
      <div class="layui-input-inline">
        <input type="text" name="passWord" lay-verify="required" placeholder="请输入密码" id="passWord" autocomplete="off" class="layui-input">
      </div>
    </div>
  
    
  <div class="layui-form-item layui-layout-admin">
      <div class="layui-input-block">
          <div class="layui-footer" style="left: 0;">
              <button class="layui-btn" lay-submit="" lay-filter="component-form-demo1">立即添加</button>
              
          </div>
      </div>
  </div>
  </div>

  <script src="../../../layuiadmin/layui/layui.js"></script>  
   <script src="../../../layuiadmin/url.js"></script>
  <script>
  layui.config({
    base: '../../../layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'form'], function(){
    var $ = layui.$
    ,form = layui.form ;
	/* 监听提交 */
	form.on('submit(component-form-demo1)', function(data) {
	    var userName = data.field.userName;
	    var passWord = data.field.passWord;
	     
	    console.log(data.field);
	    $.ajax({
	        type: 'POST',
	        dataType: 'json',
	        data: {
	            userName: userName,
	            passWord: passWord
	           
	        },
	        url: applicationUrl + 'adminsys/api/insert',
	        success: function(data) {
	            //  parent.layer.alert(JSON.stringify(data.msg));
	            layer.msg(data.msg);
	            $("#userName").val(" ");
				$("#passWord").val(" ");
	        },
	        error: function(data) {
	            layer.msg(data.msg);
 
	        }
	    })
	
	    return false;
	});
  })
  </script>
</body>
</html>